package com.pz.cloud.framework.researchProj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pz.cloud.framework.business.researchProj.entity.ResearchProjectInstructor;
import com.pz.cloud.framework.business.researchProj.service.IResearchProjectInstructorService;
import com.pz.cloud.framework.researchProj.mapper.ResearchProjectInstructorMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Description: 科研项目
 * @Author: jeecg-boot
 * @Date:   2020-12-13
 * @Version: V1.0
 */
@Service
@Transactional
public class ResearchProjectInstructorServiceImpl extends ServiceImpl<ResearchProjectInstructorMapper, ResearchProjectInstructor> implements IResearchProjectInstructorService {

    @Override
    public ResearchProjectInstructor getByProjectId(String id) {
        LambdaQueryWrapper<ResearchProjectInstructor> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(ResearchProjectInstructor::getProjectId, id);
        ResearchProjectInstructor one = getOne(queryWrapper, false);
        return one;
    }

    @Override
    public boolean removeByProjectId(String projectId) {
        LambdaUpdateWrapper<ResearchProjectInstructor> wrapper = Wrappers.lambdaUpdate();
        wrapper.eq(ResearchProjectInstructor::getProjectId, projectId);
        return remove(wrapper);
    }
}
